{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "5f2809a5",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import cv2 as cv\n",
    "\n",
    "# Create a white image\n",
    "img = np.ones((512,512,3), np.uint8)*255\n",
    "\n",
    "# Draw a diagonal blue line with thickness of 5 px\n",
    "startPt = (0,0)\n",
    "endPt   = (img.shape[1]-1, img.shape[0]-1)\n",
    "color   = (255,0,0)\n",
    "thinknessPx = 5\n",
    "cv.line(img, startPt,endPt, color,thinknessPx)\n",
    "\n",
    "cv.imshow(\"img\", img)\n",
    "cv.waitKey(0)\n",
    "cv.destroyAllWindows()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "baa0dc94",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import cv2 as cv\n",
    "\n",
    "# Create a white image\n",
    "img = np.ones((512,512,3), np.uint8)*255\n",
    "\n",
    "# rectangle\n",
    "startPt = (20,20)\n",
    "endPt   = (round(img.shape[1]/2),round(img.shape[0]/4))\n",
    "color   = (0,255,0)\n",
    "thinknessPx = 3\n",
    "cv.rectangle(img, startPt,endPt, color,thinknessPx)\n",
    "\n",
    "cv.imshow(\"img\", img)\n",
    "cv.waitKey(0)\n",
    "cv.destroyAllWindows()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "eabb3ca8",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import cv2 as cv\n",
    "\n",
    "# Create a white image\n",
    "img = np.ones((512,512,3), np.uint8)*255\n",
    "\n",
    "# circle\n",
    "center  = (round(img.shape[1]/2),round(img.shape[0]/4))\n",
    "radius  = 50\n",
    "color   = (0,255,0)\n",
    "thinknessPx = -1\n",
    "cv.circle(img, center,radius, color, thinknessPx)\n",
    "\n",
    "cv.imshow(\"img\", img)\n",
    "cv.waitKey(0)\n",
    "cv.destroyAllWindows()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "cf23a8b2",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import cv2 as cv\n",
    "\n",
    "# Create a white image\n",
    "img = np.ones((512,512,3), np.uint8)*255\n",
    "\n",
    "# ellipse\n",
    "center     = (round(img.shape[1]/2),round(img.shape[0]/4))\n",
    "axisRadius = (100,50)\n",
    "startAngleAsRef = 90+45\n",
    "startAngleFromRef,endAngleFromRef = 0, 360\n",
    "color,thinknessPx = (0,0,255), 1\n",
    "cv.ellipse(img, center,axisRadius, \n",
    "           angle,startAngle,endAngle, color,thinknessPx)\n",
    "\n",
    "\n",
    "cv.imshow(\"img\", img)\n",
    "cv.waitKey(0)\n",
    "cv.destroyAllWindows()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "50263e23",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[10  5]\n",
      " [20 30]\n",
      " [70 20]\n",
      " [50 10]]\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "import cv2 as cv\n",
    "\n",
    "# Create a white image\n",
    "img = np.ones((512,512,3), np.uint8)*255\n",
    "\n",
    "# polylines\n",
    "pts = np.array([[10,5],[20,30],[70,20],[50,10]], np.int32)\n",
    "# pts = pts.reshape((-1,1,2))\n",
    "print(pts)\n",
    "isClose = False\n",
    "color   = (0,0,255)\n",
    "cv.polylines(img, [pts], isClose, color)\n",
    "\n",
    "cv.imshow(\"img\", img)\n",
    "cv.waitKey(0)\n",
    "cv.destroyAllWindows()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "36d4d6d6",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import cv2 as cv\n",
    "\n",
    "# Create a white image\n",
    "img = np.ones((512,512,3), np.uint8)*255\n",
    "\n",
    "# text\n",
    "text = 'OpenCV'\n",
    "textBottomLeftPt = (0,511)\n",
    "fontType = cv.FONT_HERSHEY_SIMPLEX\n",
    "fontScale = 1\n",
    "color   = (0,0,255)\n",
    "thinknessPx = 1\n",
    "lineType = cv.LINE_AA\n",
    "cv.putText(img, text,textBottomLeftPt, \n",
    "           fontType,fontScale, color,thinknessPx,lineType)\n",
    "\n",
    "cv.imshow(\"img\", img)\n",
    "cv.waitKey(0)\n",
    "cv.destroyAllWindows()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5e23ce32",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
